package com.muyaxuan.mail.common;

public class PageModel {
	//每页显示条数常量
	private static final int PAGE_SIZE = 5;
	//当前页
	private int pageIndex;
	//总条数
	private int recordCount;
	//每页显示数量
	private int pageSize;
	
	public int getPageIndex() {
		this.pageIndex = pageIndex > getTotalPage() ? this.getTotalPage() : this.pageIndex;
		return pageIndex <= 1 ? 1 : pageIndex;
	}
	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
	}
	public int getRecordCount() {
		return recordCount;
	}
	public void setRecordCount(int recordCount) {
		this.recordCount = recordCount;
	}
	public int getPageSize() {
		return pageSize<=1?PAGE_SIZE:pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	//总共分了多少页
	public int getTotalPage(){
		return (this.getRecordCount()-1)/this.getPageSize()+1;
	}
	//查询时的开始行
	public int getStartRow(){
		return (this.getPageIndex()-1)*this.getPageSize();
	}
	

}
